#!/usr/bin/sh

iplist=(
192.168.0.22
192.168.0.23
192.168.0.24
.....
.....
)


for ((i=0;i<${#iplist[@]};i++))
do
        #echo "---------${iplist[i]}---------------"
	free_cpu=$(zabbix_get -s ${iplist[i]} -p 10050 -k 'system.cpu.util[,idle]')
  	used_cpu=`echo | awk "{print 100-$free_cpu}"`
	#echo $used_cpu
        
	
	total_mem=$(zabbix_get -s ${iplist[i]} -p 10050 -k 'vm.memory.size[total]')
	avail_mem=$(zabbix_get -s ${iplist[i]} -p 10050 -k 'vm.memory.size[available]')
	used_mem=`expr $total_mem - $avail_mem`
        used_mem_out=`echo | awk "{print $used_mem/$total_mem}"`
	used_mem_percent=`echo "$used_mem_out * 100"|bc`
	#echo $used_mem_percent
	
	free_pan=$(zabbix_get -s ${iplist[i]} -p 10050 -k 'vfs.fs.size[/data,pfree]')
	used_pan=`echo "100-$free_pan"|bc`
	#echo $used_pan

	now=`date "+%Y-%m-%d %H:%M:%S"`
	/data/mariadb/bin/mysql -u 'xxx' -p'xxx' -e "insert into statistics.resourceUsage values('$now','${iplist[i]}','$used_cpu','$used_mem_percent','$used_pan')"
done

